package util;

import javax.swing.*;
import javax.swing.text.DateFormatter;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.NumberFormatter;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;

public class Utli_tools {
    public static void setJFormattedTextField_int(JFormattedTextField tmp) {
        tmp.setFormatterFactory(new DefaultFormatterFactory(
                new NumberFormatter(
                        NumberFormat.getIntegerInstance())));

    }

    public static void setJFormattedTextField_double(JFormattedTextField tmp) {
        tmp.setFormatterFactory(new DefaultFormatterFactory(
                new NumberFormatter(
                        NumberFormat.getInstance())));

    }

    public static void setJFormattedTextField_date(JFormattedTextField tmp) {
        tmp.setFormatterFactory(new DefaultFormatterFactory(
                new DateFormatter(new SimpleDateFormat("yyyy-MM-dd"))));
    }



}
